﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Consul;
using Microsoft.AspNetCore.Mvc;

namespace PeerApi.Controllers
{
    /// <summary>
    /// 服务发现
    /// </summary>
    public class FindListController : Controller
    {
        /// <summary>
        /// 获取注册的列表
        /// </summary>
        /// <returns></returns>
        public IActionResult Index()
        {
            var client = new ConsulClient(ConfigurationOverview); //回调获取
                                                                  //获取所有服务  
                                                                  // var map = client.Agent.;

            return View();
        }
        /// <summary>
        /// 获取Consul的实例
        /// </summary>
        /// <param name="obj"></param>
        private static void ConfigurationOverview(ConsulClientConfiguration obj)
        {
            //consul的地址
            obj.Address = new Uri("http://127.0.0.1:8500");
            //数据中心命名
            obj.Datacenter = "dc1";
        }
    }
}